** 2021-12
** Filindra et al. "Beyond Performance: Racial Prejudice and Whites’ Mistrust of Government"
********************************************************************************

**Note on Stereotypes:
*Some years (1992,2016) ask hardworking-intelligent-peaceful
*Some years (2000,2004) ask hardworking-intelligent-trustworthy
*Some years (2008, 2012) asks hardworking and intelligent 
*2016 (& later 2020) only asks hardworking and peaceful 
*In all years we coded them in a way that higher values are negative stereotypes
*For measurement consistency, we use lazy/unintelligent for all years except 2016 & 2020 
********************************************************************************

use "C:\Work_Kaplan\NES Data\Nes 1992\NES1992.dta" 

gen wgt=V923008

******************

* trust in government

* VAR V926120    NAME-92POST:M5.TRUST IN GOVT                                    
* VAR V926121    NAME-92POST:M6.GOVT WAST TAXS                                   
* VAR V926122    NAME-92POST:M7.BIG INTRTS/ALL                                   
* VAR V926123    NAME-92POST:M8.GOVT CROOKED                                     

gen trustgov1=.
replace trustgov1=0 if V926120==7
replace trustgov1=0.3333 if V926120==5
replace trustgov1=0.66666 if V926120==3
replace trustgov1=1 if V926120==1

gen trustgov2=.
replace trustgov2=0 if V926121==5
replace trustgov2=0.5 if V926121==3
replace trustgov2=1 if V926121==1

gen trustgov3=.
replace trustgov3=0 if V926122==5
replace trustgov3=1 if V926122==1

gen trustgov4=.
replace trustgov4=0 if V926123==5
replace trustgov4=0.5 if V926123==3
replace trustgov4=1 if V926123==1

sum trustgov1 trustgov2 trustgov3 trustgov4
pwcorr trustgov1 trustgov2 trustgov3 trustgov4
egen trustgovf=rowmean(trustgov1 trustgov2 trustgov3 trustgov4)

gen trustgovo=.
replace trustgovo=0 if V926120==7
replace trustgovo=1 if V926120==5
replace trustgovo=2 if V926120==3
replace trustgovo=3 if V926120==1

* responsiveness
recode V880937 V880938 (8/9=.) (0=.)

gen effic1=(V880938-1)/4
gen effic2=(V880937-1)/4

egen efficf=rowmean(effic1 effic2)

* social trust
gen trustpf=.
replace trustpf=1 if V926139==1
replace trustpf=0 if V926139==2


***************************

* feeling therm toward present president
gen prestherm=V923305
recode prestherm (996/999=.)
gen prestherm1=prestherm/100
sum prestherm1

***************************
* econ prospective
* VAR 000496a   H4. US econ bttr/worse in next year stan
* VAR 000496b   H4.E. US econ bttr/worse in next year ex
* VAR 000497    H4a. How much better US econ in nxt year
* VAR 000498    H4b. How much worse US econ in nxt year
* VAR 000499    H4x. Summary US econ in next year

* VAR 923537 NAME-92PRE: H7.

recode V923537 (8/9=.) (0=.)

gen econpro=.
replace econpro=0 if V923537==5
replace econpro=0.5 if V923537==3
replace econpro=1 if V923537==1


****************
* authoritarianism
* VAR 926019    NAME-92POST:L3/A.CHLD-IND/RSP    
* VAR 926021    NAME-92POST:L3C.-CURIOS/MNNRS                                   
* VAR 926020    NAME-92POST:L3B.-OBED/SLF REL                                   
* VAR 926022    NAME-92POST:L3D.CONSID/WL BEH                                   

recode V926019 V926020 V926021 V926022 (8/9=.) (0=.)

gen auth1=0.5
replace auth1=0 if V926019==1
replace auth1=1 if V926019==5
replace auth1=. if V926019==.

gen auth2=0.5
replace auth2=0 if V926020==5
replace auth2=1 if V926020==1
replace auth2=. if V926020==.

gen auth3=0.5
replace auth3=0 if V926021==1
replace auth3=1 if V926021==5
replace auth3=. if V926021==.

gen auth4=0.5
replace auth4=0 if V926022==1
replace auth4=1 if V926022==5
replace auth4=. if V926022==.

sum auth1 auth2 auth3 auth4
pwcorr auth1 auth2 auth3 auth4
egen authf=rowmean(auth1 auth2 auth3 auth4)


* control variables
* age
gen age=V923903

replace age=. if V923903==98 | V923903==99 | V923903==0 

gen age1829=0
replace age1829=1 if age < 30 & age>16
replace age1829=. if age==.

gen age3044=0
replace age3044=1 if age>=30 & age<45
replace age3044=. if age==.

gen age4564=0
replace age4564=1 if age>=45 & age<65
replace age4564=. if age==.

gen age65p=0
replace age65p=1 if age>=65 & age<98
replace age65p=. if age==.

tab1 age1829 age3044 age4564 age65p

* female
gen female=V924201-1

* race
gen white=0
replace white=1 if V924202==1

gen black=0
replace black=1 if V924202==2

gen other=0
replace other=1 if black==0 & white==0


* prot
gen prot=0
replace prot=1 if V923830==1

* south
gen south=0
replace south=1 if V923017>39 & V923017<50
replace south=1 if V923017==54

* income
gen income=V924104
replace income=0 if V924104==88 | V924104==98 | V924104==99 | V924104==66 | V924104==77

gen inc1=income/24

gen incdk=0
replace incdk=1 if V924104==88 | V924104==98 | V924104==99 | V924104==66 | V924104==77

gen incq1=0
replace incq1=1 if V924104>0 & V924104<12

gen incq2=0
replace incq2=1 if V924104>11 & V924104<17

gen incq3=0
replace incq3=1 if V924104>16 & V924104<20

gen incq4=0
replace incq4=1 if V924104>19 & V924104<25

tab1 incq1 incq2 incq3 incq4 incdk [iw=wgt]

* education
tab V923908

gen ba=0
replace ba=1 if V923908==6 | V923908==7

gen degree=.
replace degree=0 if V923908==1 | V923908==2
replace degree=0.25 if V923908==3
replace degree=0.5 if V923908==4 | V923908==5
replace degree=0.75 if V923908==6
replace degree=1 if V923908==7


* partisanship
tab V923634

gen pid7=V923634
replace pid7=. if V923634==7 | V923634==9
replace pid7=3 if V923634==8

gen pid1=pid7/6

* ideology

gen ideology=V923509
replace ideology=. if V923509==8 | V923509==9 | V923509==0

replace ideology=3 if V923511==1
replace ideology=5 if V923511==5
replace ideology=3 if V923512==1
replace ideology=4 if V923512==3
replace ideology=5 if V923512==5

tab ideology, m

recode ideology (.=0)

gen ideol1=ideology/7

gen ideoldk=0
replace ideoldk=1 if ideology==0

gen year=1992


**Stereotypes
* V926221    Lazy 7-pt scale: whites
* V926222    Lazy 7-pt scale: blacks
* V926224    Lazy 7-pt scale: hispanics
* V926223    Lazy 7-pt scale: asians

* V926225    Unintelligent 7-pt scale: whites
* V926226    Unintelligent 7-pt scale: blacks
* V926228    Unintelligent 7-pt scale: hispanics
* V926227    Unintelligent 7-pt scale: asians

* V926229    Peaceful 7-pt scale: whites
* V926230    Peaceful 7-pt scale: blacks
* V926232    Peaceful 7-pt scale: hispanics
* V926231    Peaceful 7-pt scale: asians


recode V926221 V926222 V926223 V926224 V926225 V926226 V926227 V926228 V926229 V926230 V926231 V926232 (0=.)(8/9=.)

gen whitehw=(V926221-1)/6
gen blackhw=(V926222-1)/6

gen whitein=(7-V926225)/6
gen blackin=(7-V926226)/6


egen whitester=rowmean(whitehw whitein)
egen blackster=rowmean(blackhw blackin)

**Thermometer
**V925323  Feeling Thermometer: Blacks
recode V925323 (888/999=.) 
gen blacktherm=V925323
gen blacktherm1=V925323/100


**Policy variables
**PREFERENTIAL HIRING - 
**Higher numbers strongly oppose
recode V925936 (0=.) (9=.)
gen prefhire=.
replace prefhire=0 if V925936==1
replace prefhire=0.33 if V925936==2
replace prefhire=0.66 if V925936==4
replace prefhire=1 if V925936==5


**GOV HELP - SOME PEOPLE FEEL THAT THE GOVERNMENT IN WASHINGTON SHOULD MAKE EVERY EFFORT 
**TO IMPROVE THE SOCIAL AND ECONOMIC POSITION OF BLACKS. OTHERS FEEL THAT THE GOVERNMENT 
**SHOULD NOT MAKE ANY SPECIAL EFFORT TO HELP BLACKS BECAUSE THEY SHOULD HELP THEMSELVES
**Higher numbers strongly oppose
recode V923724 (0=.) (8/9=.)
gen govhelp=(V923724-1)/6

**AID TO BLACKS
**PROGRAMS THAT ASSIST BLACKS? SHOULD FEDERAL
**SPENDING BE INCREASED, DECREASED, KEPT ABOUT THE SAME, OR CUT OUT ENTIRELY 
recode V923729 (8/9=.)
gen aid=.
replace aid=0 if V923729==1
replace aid=0.33 if V923729==2
replace aid=0.66 if V923729==3
replace aid=1 if V923729==7

**Immigration levels 
recode V926235 (8/9=.) (0=.)
gen immg=(V926235-1)/4
tab immg

*******************************************************************************

use "C:\Work_Kaplan\NES Data\Nes 1996\nes96.dta", clear

gen wgt=V960005B

* gen race
gen white=0
replace white=1 if V960067==1

* trust in gov't
* VAR V960566

* 960566    Pre. How much of the time does R trust the fed govt to do right

* 961251    Post. How much of the time R trusts the govt to do what is right
* 961252    Post. How much of tax money does R think the govt wastes
* 961253    Post. Is govt run by a few big interests or the benefit of all
* 961254    Post. How many of the people in govt are crooked

tab1 V961251 V961252 V961253 V961254

recode V961251 V961252 V961253 V961254 (8/9=.) (0=.)

recode V961251 (3/4=0) (2=0.5)
recode V961252 (1=0) (3=0.5) (5=1)
recode V961253 (1=0) (5=1)
recode V961254 (1=0) (3=0.5) (5=1)

sum V961251 V961252 V961253 V961254
pwcorr V961251 V961252 V961253 V961254

egen trustgovf=rowmean(V961251 V961252 V961253 V961254)

******************************

* responsiveness
recode V961244 V961245 (8/9=.) (0=.)

gen effic1=(V961244-1)/4
gen effic2=(V961245-1)/4

egen efficf=rowmean(effic1 effic2)

******************************

* lazy whites V961311
* lazy blacks V961312

* intelligent whties V961314
* intelligent blacks V961315


recode V961311 V961312 V961314 V961315 (8/9=.) (0=.)
gen stereobl1=(V961312-1)/6
gen stereobl2=(V961315-1)/6

egen stereoblf=rowmean(stereobl1 stereobl2)
gen blackster=stereoblf


*  Black thermometer 
recode V961029 (996/999=.)
gen blacktherm1=V961029/100
********************

* racialized policies

* V961208    Post. Does R favor affirmative action in hiring and promotion
* V961209    Post. Does R favor/oppose affir action strongly / not strongly

recode V961209 (8/9=.) (0=.)
gen prefhire=.
replace prefhire=0 if V961209==1
replace prefhire=0.333 if V961209==2
replace prefhire=0.666 if V961209==4
replace prefhire=1 if V961209==5

* V960487    Pre. R's self-place on aid to blacks scale
* V961210    Post. R's position on aid to blacks - 7 point scale

sum V960487 V961210

recode V960487 V961210 (8/9=.) (0=.)
gen govhelp=(7-V960487)/6
gen aidpost=(7-V961210)/6

***********************

* prospective sociotropic economic evaluation

recode V960388 (8/9=.) (0=.)

gen econpro=(5-V960388)/4

*********************************


* trust in people
* 960567    Pre. Does R think that most people can be trusted
* 961258    Post. Does R think that people can be trusted

recode V961258 (8/9=.) (0=.)

gen trustpf=.
replace trustpf=1 if V961258==1
replace trustpf=0 if V961258==5


****************
* authoritarianism

* these items were not asked in 1996 (though were asked in 1992 and 2000)

*************************

* presidential thermometer
* 960272    Pre. Clinton feeling thermometer
* 961019    Post. Feeling thermometer - Bill Clinton
gen prestherm=V960272
recode prestherm (996/999=.)
gen prestherm1=prestherm/100
sum prestherm1



*********************

* ideology
recode V960365 (8/9=.)
recode V960366 (0=.) (8=.)

gen ideology=V960365
replace ideology=3 if V960365==4 & V960366==1
replace ideology=5 if V960365==4 & V960366==2
replace ideology=4 if V960365==4 & V960366==3
replace ideology=4 if V960365==4 & V960366==7

replace ideology=3 if V960365==0 & V960366==1
replace ideology=5 if V960365==0 & V960366==2
replace ideology=4 if V960365==0 & V960366==3
replace ideology=0 if V960365==0 & V960366==7

replace ideology=3 if V960365==. & V960366==1
replace ideology=5 if V960365==. & V960366==2
replace ideology=4 if V960365==. & V960366==3
replace ideology=0 if V960365==. & V960366==7

replace ideology=3 if V960365==. & V960366==1
replace ideology=5 if V960365==. & V960366==2
replace ideology=4 if V960365==. & V960366==3
replace ideology=0 if V960365==. & V960366==7
replace ideology=0 if V960365==. & V960366==.

gen ideol1=(ideology)/7

gen ideoldk=0
replace ideoldk=1 if ideology==0

* partisanship
gen pid1=V960420/6
replace pid1=. if V960420==7 | V960420==8 | V960420==9

*********
* control variables

generate south= 0
replace south = 1 if V960109> 39 & V960109< 50 | V960109==54
* label variable south "Reside in South"

* religion V960581 V960582
gen prot=0
replace prot=1 if V960581==1 | V960582==1


* female V960066

gen female=0
replace female=1 if V960066==2

* age V960096 V960605 

gen age=V960605
replace age=. if V960605==98 | V960605==99 | V960605==0 

gen age1829=0
replace age1829=1 if age < 30
replace age1829=. if age==.

gen age3044=0
replace age3044=1 if age>=30 & age<45
replace age3044=. if age==.

gen age4564=0
replace age4564=1 if age>=45 & age<65
replace age4564=. if age==.

gen age65p=0
replace age65p=1 if age>=65
replace age65p=. if age==.

* education V960610

recode V960610 (8/9=.)

gen ba=0
replace ba=1 if V960610==6 | V960610==7


gen degree=.
replace degree=0 if V960610==1 | V960610==2
replace degree=0.25 if V960610==3
replace degree=0.5 if V960610==4 | V960610==5
replace degree=0.75 if V960610==6
replace degree=1 if V960610==7


* household income
recode V960701 (88/99=.)

gen income=V960701/24
replace income=0 if V960701==.

gen incdk=0
replace incdk=1 if V960701==.

* immigration levels
recode V961325 (8/9=.) (0=.)
gen immg=(V961325-1)/4
tab immg


**************************************
**************************************

use "C:\Work_Kaplan\NES Data\Nes 2000\nes2000.dta", clear

* VAR 000002    Process.5. Sample weight
* VAR 000002a   Process.5a. Post weight
* Weight (individual)
gen wgt=v000002a

* race 
* VAR 001006a   Y30(1). Racial group #1 self-description
gen white=0
replace white=1 if  v001006a==50

gen black=0
replace black=1 if v001006a==10

gen hisp=0
replace hisp=1 if v001006a==40

gen other=0
replace other=1 if v001006a!=10 & v001006a!=40 & v001006a!=50

* keep if white==1

* trust federal gov't
gen trustgov1=v001534
replace trustgov1=. if v001534==8 | v001534==9 | v001534==0 | v001534==.
replace trustgov1=0 if v001534==4
replace trustgov1=0.3333 if v001534==3
replace trustgov1=0.6666 if v001534==2
replace trustgov1=1 if v001534==1

gen trustgov2=.
replace trustgov2=0 if v001535==1
replace trustgov2=0.5 if v001535==3
replace trustgov2=1 if v001535==5

gen trustgov3=.
replace trustgov3=0 if v001536==1
replace trustgov3=1 if v001536==5

gen trustgov4=.
replace trustgov4=0 if v001537==1
replace trustgov4=0.5 if v001537==3
replace trustgov4=1 if v001537==5

sum trustgov1 trustgov2 trustgov3 trustgov4
pwcorr trustgov1 trustgov2 trustgov3 trustgov4
egen trustgovf=rowmean(trustgov1 trustgov2 trustgov3 trustgov4)

alpha trustgov1 trustgov2 trustgov3 trustgov4

factor trustgov1 trustgov2 trustgov3 trustgov4
predict trustgovd1
pwcorr trustgovd1 trustgovf

gen trustgovo=v001534
replace trustgovo=. if v001534==8 | v001534==9 | v001534==0
replace trustgovo=0 if v001534==4
replace trustgovo=1 if v001534==3
replace trustgovo=2 if v001534==2
replace trustgovo=3 if v001534==1

* responsiveness
recode v001527 v001528 (8/9=.) (0=.)

gen effic1=(v001527-1)/4
gen effic2=(v001528-1)/4

egen efficf=rowmean(effic1 effic2)

* social trust
gen trustpf=.
replace trustpf=1 if v001475==1
replace trustpf=0 if v001475==5


*******************

* current pres. feeling therm.
gen ftpres=v001292    
recode ftpres(995/999=.)
gen prestherm1=ftpres/100

*******************


* prospective sociotropic economic evaluation
gen econpro=(5-v000499)/4

******************


* Authoritarianism index
* VAR 001586    R5a. Independence or respect for elders
* VAR 001587    R5b. Obedience or self-reliance
* VAR 001588    R5c. Curiosity or good manners
* VAR 001589    R5d. Considerate or well behaved

recode v001586 v001587 v001588 v001589  (8/9=.)

gen auth1=0.5
replace auth1=0 if v001586==1
replace auth1=1 if v001586==5
replace auth1=. if v001586==.

gen auth2=0.5
replace auth2=0 if v001587==5
replace auth2=1 if v001587==1
replace auth2=. if v001587==.

gen auth3=0.5
replace auth3=0 if v001588==1
replace auth3=1 if v001588==5
replace auth3=. if v001588==.

gen auth4=0.5
replace auth4=0 if v001589==1
replace auth4=1 if v001589==5
replace auth4=. if v001589==.

egen authf=rowmean(auth1 auth2 auth3 auth4)

******************************

* age
* VAR 000908    Y1x. Respondent age

gen age=v000908
replace age=. if v000908==98 | v000908==99 | v000908==0 

gen age1829=0
replace age1829=1 if age < 30
replace age1829=. if age==.

gen age3044=0
replace age3044=1 if age>=30 & age<45
replace age3044=. if age==.

gen age4564=0
replace age4564=1 if age>=45 & age<65
replace age4564=. if age==.

gen age65p=0
replace age65p=1 if age>=65
replace age65p=. if age==.

* gender 
* VAR 001029    ZZ1. IWR obs: R gender
gen female=0
replace female=1 if v001029==2

* Protestant
* VAR 000882    X3a. Attend protestant/Cath/Jewish/other
* VAR 000883    X3b. Belong protestant/Cath/Jewish/other

gen prot=0
replace prot=1 if v000882==1 | v000883==1


* South
* VAR 000079    Pre.Sample.1. ICPSR state code

generate south= 0
replace south = 1 if v000079> 39 & v000079< 50 | v000079==54
label variable south "Reside in South"
* label values south yesno

* INCOME
* CONTINUOUS INCOME
* use respondent income (v000997) if household income (v000994) not reported 
gen income=v000994/22
replace income=v000997/22 if v000994==.
replace income=0 if v000994==. & v000997==. 

gen incnk=0
replace incnk=1 if v000994==. & v000997==. 


* VAR 000913    Y3x. R educ summary
* education (remember, all dichotomous variables must be coded 0,1)
gen educ=v000913
replace educ=. if v000913==8 | v000913==9

gen ba=0
replace ba=1 if v000913==6 | v000913==7
replace ba=. if v000913==8 | v000913==9 | v000913==.

gen degree=(v000913-1)/6

* VAR 000523    K1x. Party ID summary
gen partyid=v000523
replace partyid=. if v000523==7 | v000523==8 | v000523==9 | v000523==.

gen pid1=partyid/6

gen dem=0
replace dem=1 if v000523==0 | v000523==1
replace dem=. if v000523==7 | v000523==8 | v000523==9 | v000523==.

gen ind=0
replace ind=1 if v000523==2 | v000523==3 | v000523==4
replace ind=. if v000523==7 | v000523==8 | v000523==9 | v000523==.

gen rep=0
replace rep=1 if v000523==5 | v000523==6
replace rep=. if v000523==7 | v000523==8 | v000523==9 | v000523==.


* VAR 000446    G6x1. Summary self plcmnt lib-con scale/brnch
gen ideology=v000446-1
gen ideol1=ideology/6
replace ideol1=0 if v000447==7

gen ideoldk=0
replace ideoldk=1 if v000447==7

gen year=2000

gen inc1=income
gen incdk=incnk


*******************************************************************************
**Stereotypes

* V001574    Hardworking 7-pt scale: whites
* V001575    Hardworking 7-pt scale: blacks
* V001576    Hardworking 7-pt scale: hispanics
* V001577    Hardworking 7-pt scale: asians

* V001578    Intelligent 7-pt scale: whites
* V001579    Intelligent 7-pt scale: blacks
* V001580    Intelligent 7-pt scale: hispanics
* V001581    Intelligent 7-pt scale: asians

* V001582     Trustworthy 7-pt scale: whites
* V001583     Trustworthy 7-pt scale: blacks
* V001584     Trustworthy 7-pt scale: hispanics
* V001585     Trustworthy 7-pt scale: asians

recode V001574 V001575 V001576 V001577 V001578 V001579 V001580 V001581 (0=.)(8/9=.)

gen whitehw=(V001574-1)/6
gen blackhw=(V001575-1)/6


gen whitein=(V001578-1)/6
gen blackin=(V001579-1)/6


egen whitester=rowmean(whitehw whitein)
egen blackster=rowmean(blackhw blackin)

**Thermometer
**V001308  Feeling Thermometer: Blacks
recode V001308 (996/999=.) 
gen blacktherm=V001308
gen blacktherm1=V001308/100

**Policy variables 
**PREFERENTIAL HIRING - 
**Higher numbers strongly oppose
recode V000806 (0=.) (9=.)
gen prefhire=.
replace prefhire=0 if V000806==1
replace prefhire=0.33 if V000806==2
replace prefhire=0.66 if V000806==4
replace prefhire=1 if V000806==5

**GOV HELP - SOME PEOPLE FEEL THAT THE GOVERNMENT IN WASHINGTON SHOULD MAKE EVERY EFFORT 
**TO IMPROVE THE SOCIAL AND ECONOMIC POSITION OF BLACKS. OTHERS FEEL THAT THE GOVERNMENT 
**SHOULD NOT MAKE ANY SPECIAL EFFORT TO HELP BLACKS BECAUSE THEY SHOULD HELP THEMSELVES
**Higher numbers strongly oppose
recode V000641 (0=.) (8/9=.)
gen govhelp=(V000641-1)/6

**immigration levels
recode V000510 (8/9=.) (0=.)
gen immg=(V000510-1)/4
tab immg
*******************************************************************************

use "C:\Work_Kaplan\NES Data\Nes 2004\anes2004TSdta\anes2004TS.dta", clear

* Weight (individual)
gen wgt=V040102


* TRUST GOVERNMENT
* V045197     M1a. How often trust government in Washington to do right
* V045198     M1b. Is govt run by few big interests or benefit of all
* V045199     M1c. How much does government waste tax money
* V045200     M1d. How many crooked people running government

* trust in federal gov't
gen trustgovo=4-V045197
replace trustgovo=. if V045197==8 | V045197==9

gen trustgov1=(4-V045197)/3
replace trustgov1=. if V045197==8 | V045197==9

gen trustgov2=.
replace trustgov2=0 if V045198==1
replace trustgov2=1 if V045198==5

gen trustgov3=.
replace trustgov3=0 if V045199==1
replace trustgov3=0.5 if V045199==3
replace trustgov3=1 if V045199==5

gen trustgov4=.
replace trustgov4=0 if V045200==1
replace trustgov4=0.5 if V045200==3
replace trustgov4=1 if V045200==5

sum trustgov1 trustgov2 trustgov3 trustgov4
pwcorr trustgov1 trustgov2 trustgov3 trustgov4
egen trustgovf=rowmean(trustgov1 trustgov2 trustgov3 trustgov4)

alpha trustgov1 trustgov2 trustgov3 trustgov4

factor trustgov1 trustgov2 trustgov3 trustgov4
predict trustgovd1
pwcorr trustgovd1 trustgovf


* TRUST GOVERNMENT
* V045197     M1a. How often trust government in Washington to do right
* V045198     M1b. Is govt run by few big interests or benefit of all
* V045199     M1c. How much does government waste tax money
* V045200     M1d. How many crooked people running government

recode V045197 V045198 V045199 V045200(8/9=.)
gen V045197n=(4-V045197)/3

gen V045198n=0
replace V045198n=1 if V045198==5
replace V045198n=. if V045198==.

gen V045199n=0
replace V045199n=0.5 if V045199==3
replace V045199n=1 if V045199==5 
replace V045199n=. if V045199==.

gen V045200n=0
replace V045200n=0.5 if V045200==3
replace V045200n=1 if V045200==5
replace V045200n=. if V045200==.

tab1 V045197n V045198n V045199n V045200n
sum V045197n V045198n V045199n V045200n
pwcorr V045197n V045198n V045199n V045200n

egen trustgovt=rowmean(V045197n V045198n V045199n V045200n)
pwcorr trustgovt trustgovf


* responsiveness
recode V045201 V045202 (8/9=.) (0=.)

gen effic1=(V045201-1)/4
gen effic2=(V045202-1)/4

egen efficf=rowmean(effic1 effic2)

* social trust
gen trustpf=.
replace trustpf=1 if V045186==1
replace trustpf=0 if V045186==5

* race(remember, all dichotomous variables must be coded 0,1)
gen white=0
replace white=1 if V043299==50
replace white=. if V043299==88 | V043299==89

gen black=0
replace black=1 if V043299==10
replace black=. if V043299==88 | V043299==89

gen hisp=0
replace hisp=1 if V043299==40
replace hisp=. if V043299==88 | V043299==89

gen other=0
replace other=1 if V043299!=10 & V043299!=40 & V043299!=50
replace other=. if V043299==88 | V043299==89


************************************

* current pres. feeling thermometer
gen ftpres=V043038
recode ftpres (777/999=.)
gen prestherm1=ftpres/100

********************

* prospective sociotropic economic evaluation

tab1 V043099 V043100
tab V043099 V043100
tab V043100, nol m

gen econpro=(5-V043100)/4
replace econpro=. if V043100==. | V043100==8 | V043100==9

*****************

* Authoritarianism index
* V045208     N1a. Qualities for children: Independent or respect elders
* V045209     N1b. Qualities for children: Curiosity or good manners
* V045210     N1c. Qualities for children: Obedience or self-reliance
* V045211     N1d. Qualities for children: Considerate or well behaved

recode V045208 V045209 V045210 V045211 (8/9=.)

gen auth1=0.5
replace auth1=0 if V045208==1
replace auth1=1 if V045208==5
replace auth1=. if V045208==.

gen auth2=0.5
replace auth2=0 if V045209==1
replace auth2=1 if V045209==5
replace auth2=. if V045209==.

gen auth3=0.5
replace auth3=0 if V045210==5
replace auth3=1 if V045210==1
replace auth3=. if V045210==.

gen auth4=0.5
replace auth4=0 if V045211==1
replace auth4=1 if V045211==5
replace auth4=. if V045211==.

egen authf=rowmean(auth1 auth2 auth3 auth4)

******************************************

generate south= 0
replace south = 1 if V041203> 39 & V041203< 50 | V041203==54
label variable south "Reside in South"
label values south yesno

* V043230a    X3a. (Attends) R major religious group
gen prot=0
replace prot=1 if V043230a==1 | V043230b==1

****************************************

* age
gen age=V043250
replace age=. if V043250==98 | V043250==99 | V043250==0 

gen age1829=0
replace age1829=1 if age < 30
replace age1829=. if age==.

gen age3044=0
replace age3044=1 if age>=30 & age<45
replace age3044=. if age==.

gen age4564=0
replace age4564=1 if age>=45 & age<65
replace age4564=. if age==.

gen age65p=0
replace age65p=1 if age>=65
replace age65p=. if age==.

* gender (remember, all dichotomous variables must be coded 0,1)
gen female=0
replace female=1 if V041109a==2

* INCOME
* CONTINUOUS INCOME

gen income=V043293x/23
replace income=0 if V043293x==88 | V043293x==89 | V043293x==0 | V043293x==.

gen incnk=0
replace incnk=1 if V043293x==88 | V043293x==89 | V043293x==0 | V043293x==.

* education (remember, all dichotomous variables must be coded 0,1)
gen educ=V043254
replace educ=. if V043254==8 | V043254==9

gen ba=0
replace ba=1 if V043254==6 | V043254==7
replace ba=. if V043254==8 | V043254==9

gen degree=(V043254-1)/6
replace degree=0 if V043254==0

* ideology
gen ideology=V043085-1
replace ideology=0 if V043085==80 | V043085==88 | V043085==89
replace ideology=2 if V043085==80 & V043085a==1
replace ideology=3 if V043085==80 & V043085a==5
replace ideology=4 if V043085==80 & V043085a==3
replace ideology=2 if V043085==4 & V043085a==1
replace ideology=3 if V043085==4 & V043085a==5
replace ideology=4 if V043085==4 & V043085a==3

replace ideology=0 if V043085==80 & V043085a==8
replace ideology=0 if V043085==88 & V043085a==8
replace ideology=0 if V043085==89 & V043085a==.

gen ideol1=ideology/6

gen ideoldk=0
replace ideoldk=1 if V043085==80 & V043085a==8
replace ideoldk=1 if V043085==88 & V043085a==8
replace ideoldk=1 if V043085==89 & V043085a==.

* partisanship
gen partyid=V043116
replace partyid=. if V043116==7 | V043116==8 | V043116==9

gen pid1=partyid/6


gen inc1=income
gen incdk=incnk

gen year=2004

*******************************************************************************
**Stereotypes
* V045222     P4a. Hardworking 7-pt scale: whites
* V045223     P4b. Hardworking 7-pt scale: blacks
* V045226     P5a. Intelligent 7-pt scale: whites
* V045227     P5b. Intelligent 7-pt scale: blacks
* V045230     P6a. Trustworthy 7-pt scale: whites
* V045231     P6b. Trustworthy 7-pt scale: blacks

recode V045222 V045223 V045226 V045227 V045230 V045231 (8/9=.)

gen whitehw=(V045222-1)/6
gen blackhw=(V045223-1)/6
gen whitein=(V045226-1)/6
gen blackin=(V045227-1)/6

egen whitester=rowmean(whitehw whitein)
egen blackster=rowmean(blackhw blackin)

**Thermometer
**V045077  Feeling Thermometer: Blacks
recode V045077 (888/889=.) 
gen blacktherm1=V045077/100

**Policy variables 
**PREFERENTIAL HIRING - 
**Higher numbers strongly oppose
recode V045207a (8/9=.)
gen prefhire=.
replace prefhire=0 if V045207a==1
replace prefhire=0.33 if V045207a==2
replace prefhire=0.66 if V045207a==4
replace prefhire=1 if V045207a==5

**GOV HELP - SOME PEOPLE FEEL THAT THE GOVERNMENT IN WASHINGTON SHOULD MAKE EVERY EFFORT 
**TO IMPROVE THE SOCIAL AND ECONOMIC POSITION OF BLACKS. OTHERS FEEL THAT THE GOVERNMENT 
**SHOULD NOT MAKE ANY SPECIAL EFFORT TO HELP BLACKS BECAUSE THEY SHOULD HELP THEMSELVES
**Higher numbers strongly oppose
recode V043158 (80/89=.)
gen govhelp=(V043158-1)/6

**immigration levels
recode V045115 (8/9=.)
gen immg=(V045115-1)/4
tab immg
*******************************************************************************

* use "C:\Work_Kaplan\NES Data\NES 2008\ANES2008TSpor\anes2008ts.dta", clear
use "C:\Work_Kaplan\NES Data\NES_2008_Feb_2012\anes_timeseries_2008.dta", clear

* Weight (individual)
gen wgt=V080102

* RACE
* white
gen white=0
replace white=1 if V083251a==50 | V083251a==85
replace white=. if V083251a==.
replace white=. if V083251a==-8 | V083251a==-9

gen black=0
replace black=1 if V083251a==10
replace black=. if V083251a==.
replace black=. if V083251a==-8 | V083251a==-9

gen hisp=0
replace hisp=1 if V083251a==40
replace hisp=. if V083251a==.
replace hisp=. if V083251a==-8 | V083251a==-9

gen other=0
replace other=1 if V083251a!=10 & V083251a!=40 & V083251a!=50
replace other=. if V083251a==.
replace other=. if V083251a==-8 | V083251a==-9

* keep if white==1

****************

* TRUST IN GOVERNMENT [ or DISTRUST]
* V085147a    M1a1. [OLD] How often trust govt in Wash to do what is right
* V085147b    M1a2. [NEW] How oft trust govt in Wash to make fair decision
* V085148 Numeric Dec 0 M1b M1b. Govt run by a few big interests or for benefit of
* V085149 „© FWD/REV Numeric Dec 0 M1c M1c. Does government waste much tax money
* V085150 „© FWD/REV Numeric Dec 0 M1d M1d. How many in government are crooked

gen trustgov1=.
replace trustgov1=1 if V085147b==1
replace trustgov1=2 if V085147b==2
replace trustgov1=3 if V085147b==3 | V085147b==4
replace trustgov1=4 if V085147b==5

recode V085147a (-9/-1=.)
recode V085147b (-9/-1=.)

gen trustgovo=(4-V085147a)
gen trustgova=(5-V085147b)

egen trustgov2=rowmean(trustgov1 V085147a)
gen V085147n=(4-trustgov2)/3

gen V085148n=0
replace V085148n=1 if V085148==5
replace V085148n=. if V085148==.
replace V085148n=. if V085148==-8 | V085148==-9 | V085148==-2

gen V085149n=0
replace V085149n=1 if V085149==5 | V085149==3
replace V085149n=. if V085149==.
replace V085149n=. if V085149==-8 | V085149==-9 | V085149==-2

gen V085150n=0
replace V085150n=0.5 if V085150==3
replace V085150n=1 if V085150==5
replace V085150n=. if V085150==.
replace V085150n=. if V085150==-8 | V085150==-9 | V085150==-2

pwcorr V085147n V085148n V085149n V085150n
egen trustgovf=rowmean(V085147n V085148n V085149n V085150n)


* responsiveness
recode V085151c V085152c V085153a V085153b (-9/-1=.)

recode V083079c V083080c (-9/-1=.)

gen effic1=(V085151c-1)/4
replace effic1=(V085153a-1)/4 if V085151c==.
replace effic1=(V085153b-1)/4 if V085151c==. & V085153a==.
replace effic1=(V085151c+V085153a-2)/8 if V085151c!=. & V085153a!=.
replace effic1=(V085151c+V085153b-2)/8 if V085151c!=. & V085153b!=.
replace effic1=(V083079c-1)/4 if V085151c==. & V085153a==. & V085153b==.
replace effic1=(5-V085152c)/4 if V085151c==. & V085153a==. & V085153b==. & V083079c==.
replace effic1=(5-V083080c)/4 if V085151c==. & V085153a==. & V085153b==. & V083079c==. & V085152c==.
replace effic1=(10-V083080c-V085152c)/8 if V085151c==. & V085153a==. & V085153b==. & V083079c==. & V083080c~=. & V085152c~=.

recode V083079d V083080d V085151d V085152d (-9/-1=.)

gen effic2=(V085151d-1)/4
replace effic2=(V083079d-1)/4 if V085151d==.
replace effic2=(V085151d+V083079d-2)/8 if V085151d~=. & V083079d~=.
replace effic2=(5-V085152d)/4 if V085151d==. & V083079d==.
replace effic2=(5-V083080d)/4 if V085151d==. & V083079d==. & V085152d==.
replace effic2=(10-V085152d-V083080d)/8 if V085151d==. & V083079d==. & V085152d!=. & V083080d!=.

egen efficf=rowmean(effic1 effic2)

* TRUST IN PEOPLE
* V083092a    F8a. [VERSION G] Can people be trusted
* V083092b    F8b. [VERSION H] Can people be trusted
gen trustp1=0
replace trustp1=1 if V083092a==1
replace trustp1=. if V083092a==-8 | V083092a==-9 | V083092a==-1
gen trustp2=0
replace trustp2=1 if V083092b==1 | V083092b==2
replace trustp2=. if V083092b==-8 | V083092b==-9 | V083092b==-1
egen trustpf=rowmean(trustp1 trustp2)
recode trustpf (0.5=1)


* V083036 B1a. Feeling Thermometer: president (GW Bush)
* V085063a Feeling Thermometer: president (GW Bush) (POST)
* 777. Don't recognize
* 888. Don't know where to rate
* 889. Refused
* INAP. no post IW

gen ftbushpre=V083036
gen ftbushpost=V085063a

recode ftbushpre ftbushpost (-9/-1=.) (777=.) (888=.) (889=.)  

egen ftpres=rowmean(ftbushpre ftbushpost)
gen prestherm1=ftpres/100

*******************************

* economic evaluations: national and prospective
* V083084x econ pro split sample (old wording)
* V083085x econ pro split sample (new ording -- mentions Obama)

recode V083058x V083083x V083084x V083085x (-9/-1=.)
gen perpro=(5-V083058x)/4
gen onatpro=(5-V083084x)/4
gen nnatpro=(5-V083085x)/4
egen natpro=rowmean(onatpro nnatpro)
egen econpro=rowmean(natpro perpro)

***********************
* Authoritarianism index

recode V085158 V085159 V085160 V085161 (-9/-8=.) (-2=.)

gen auth1=0
replace auth1=1 if V085158==5
replace auth1=0.5 if V085158==3
replace auth1=. if V085158==.

gen auth2=0
replace auth2=1 if V085159==5
replace auth2=0.5 if V085159==3
replace auth2=. if V085159==.

gen auth3=0
replace auth3=1 if V085160==1
replace auth3=0.5 if V085160==3
replace auth3=. if V085160==.

gen auth4=0
replace auth4=1 if V085161==5
replace auth4=0.5 if V085161==3
replace auth4=. if V085161==.

egen authf =rowmean(auth1 auth2 auth3 auth4)

*******************************************

****age (code two operationalizations: continuous and dummied out into 18-29, 30-44, 45-64, 65p)

* continuous

recode V081104 (-9/-8=.)
gen age=V081104

* five dummy variables (last one for those who do not report their age)
gen age1829=0
replace age1829=1 if V081104<30
* replace age1829=. if V081104==.

gen age3044=0
replace age3044=1 if V081104>=30 & V081104<45
* replace age3044=. if V081104==.

gen age4564=0
replace age4564=1 if V081104>=45 & V081104<65
* replace age4564=. if V081104==.

gen age65p=0
replace age65p=1 if V081104>=65
* replace age65p=. if V081104==.

gen agenk=0
replace agenk=1 if V081104==.

* gender
gen female=0
replace female=1 if V083311==2
replace female=. if V083311==.

* protestant
gen prot=0
replace prot=1 if V083188a==1 | V083188b==1

***********************************************

****education (three operationizations: continuous in years, degree level (0-7) and BA or not BA)

* 1) education -- continuous in years

gen eduyears=V083217

* 2) education by degree (ordinal variable)
recode V083218x (-9/-8=.)

gen degree=(V083218x-1)/6
replace degree=0 if V083218x==0
replace degree=. if V083218x==.

* 3)  BA, no BA (binary)
gen BA=0
replace BA=1 if V083218x>5
replace BA=. if V083218x==.

***********************************************

**** (three operationalizations: continuous, by quartile, and then continuous, but code missing as zero and add a dummy variable 
****for answered income question or not answer income question).

* NEW INCOME
* CONTINUOUS INCOME for COMBINED

gen income=(V083248x)/25
* recode income (25=23) (24=23)
replace income=0 if V083248x==.
replace income=0 if V083248x==-9 | V083248x==-8

gen incnk=0
replace incnk=1 if V083248x==.
replace incnk=1 if V083248x==-9 | V083248x==-8


***********************************************

****partisanship (two operationalizations: 7 pt. scale 
recode V083098x (-1=3)
gen partyid=V083098x
tab partyid
gen pid1=partyid/6

****ideology (7 pt scale)

gen ideology=V083069-1

replace ideology=2 if V083069a==1
replace ideology=3 if V083069a==5
replace ideology=4 if V083069a==3

replace ideology=0 if V083069==. & V083069a==.
replace ideology=0 if V083069==-9 & V083069a==-1
replace ideology=0 if V083069==-8 & V083069a==-8
replace ideology=0 if V083069==-7 & V083069a==-8
replace ideology=0 if V083069==-7 & V083069a==-9

gen ideol1=ideology/6

tab1 V083069 ideology ideol1

gen ideoldk=0
replace ideoldk=1 if V083069==. & V083069a==.
replace ideoldk=1 if V083069==-9 & V083069a==-1
replace ideoldk=1 if V083069==-8 & V083069a==-8
replace ideoldk=1 if V083069==-7 & V083069a==-8
replace ideoldk=1 if V083069==-7 & V083069a==-9

tab1 V083069 ideology ideol1 ideoldk

***********************************************


* south
gen south=0
replace south=1 if V081201a=="AL" | V081201a=="AR" | V081201a=="FL" | V081201a=="GA" |V081201a=="LA" | V081201a=="MS" | V081201a=="NC" | V081201a=="SC" | V081201a=="TN" | V081201a=="TX" | V081201a=="VA"

***************************************


gen inc1=income
gen incdk=incnk

gen year=2008



recode V085174a V085174b V085174c V085174d V085175a V085175b V085175c V085175d (-9/-8=.) (-2=.)
gen whitehw=(V085174a-1)/6
gen blackhw=(V085174b-1)/6
gen latinohw=(V085174c-1)/6
gen asianhw=(V085174d-1)/6

gen whitein=(V085175a-1)/6
gen blackin=(V085175b-1)/6
gen latinoin=(V085175c-1)/6
gen asianin=(V085175d-1)/6

pwcorr whitehw whitein blackhw blackin latinohw latinoin asianhw asianin 

egen whitester=rowmean(whitehw whitein)
egen blackster=rowmean(blackhw blackin)

***Thermometer
**V085064y  Feeling Thermometer: Blacks
recode V085064y(-9/-2=.) 
gen blacktherm1=V085064y/100

**Policy variables 
**PREFERENTIAL HIRING - 
**Higher numbers strongly oppose

gen prefhire=.
replace prefhire=0 if V085157a==1
replace prefhire=0.33 if V085157a==5
replace prefhire=0.66 if V085157b==5
replace prefhire=1 if V085157b==1

**GOV HELP - SOME PEOPLE FEEL THAT THE GOVERNMENT IN WASHINGTON SHOULD MAKE EVERY EFFORT 
**TO IMPROVE THE SOCIAL AND ECONOMIC POSITION OF BLACKS. OTHERS FEEL THAT THE GOVERNMENT 
**SHOULD NOT MAKE ANY SPECIAL EFFORT TO HELP BLACKS BECAUSE THEY SHOULD HELP THEMSELVES
**Higher numbers strongly oppose
recode V083137 (-9/-7=.)
gen govhelp=(V083137-1)/6

**immigration levels
recode V085082 (-9/-2=.)
gen immg=(V085082-1)/4
tab immg

*******************************************************************************

use "C:\Work_Kaplan\NES Data\NES2012_Updated_2014_05_20\anes_timeseries_2012_dta\anes_timeseries_2012_stata12.dta", clear

* Weight (weights by mode and for full sample; below is for full sample)
gen wgt=weight_full

* RACE
recode dem_raceeth (-9/-8=.)

* white (Non-Hispanic)
gen white=0
replace white=1 if  dem_raceeth==1
replace white=. if dem_raceeth==.

gen black=0
replace black=1 if dem_raceeth==2
replace black=. if dem_raceeth==.

gen hisp=0
replace hisp=1 if dem_raceeth==5
replace hisp=. if dem_raceeth==.

gen other=0
replace other=1 if dem_raceeth==6
replace other=. if dem_raceeth==.

* keep if white==1


* TRUST GOVERNMENT
* V045197     M1a. How often trust government in Washington to do right
* V045198     M1b. Is govt run by few big interests or benefit of all
* V045199     M1c. How much does government waste tax money
* V045200     M1d. How many crooked people running government

* trustgov_trustgrev
* trustgov_trustgstd
* trustgov_bigintrst
* trustgov_waste
* trustgov_corrpt

* tab1 trustgov_trustgrev trustgov_trustgstd trustgov_bigintrst trustgov_waste trustgov_corrpt

recode trustgov_trustgrev trustgov_trustgstd trustgov_bigintrst trustgov_waste trustgov_corrpt (-9/-1=.)

gen trustgovo=.
replace trustgovo=(4-trustgov_trustgstd) if trustgov_trustgrev==.

gen trustgova=.
replace trustgova=(5-trustgov_trustgrev) if trustgov_trustgstd==.

gen trustgov1=(5-trustgov_trustgrev)/4
replace trustgov1=(4-trustgov_trustgstd )/3 if trustgov_trustgrev==.

gen trustgov3=0
replace trustgov3=1 if trustgov_bigintrst==2
replace trustgov3=. if trustgov_bigintrst==.

gen trustgov4=0
replace trustgov4=0.5 if trustgov_waste==2
replace trustgov4=1 if trustgov_waste==3
replace trustgov4=. if trustgov_waste==.

gen trustgov5=(trustgov_corrpt-1)/4
replace trustgov5=. if trustgov_corrpt==.

tab1 trustgov1 trustgov3 trustgov4 trustgov5
pwcorr trustgov1 trustgov3 trustgov4 trustgov5
egen trustgovf=rowmean(trustgov1 trustgov3 trustgov4 trustgov5)

* responsiveness
recode effic_saystd effic_carestd effic_carerev effic_sayrev (-9/-1=.)
recode efficpo_carestd efficpo_saystd efficpo_carerev efficpo_sayrev (-9/-1=.)


gen effic1f=(efficpo_carestd-1)/4
replace effic1f=(effic_carestd-1)/4 if efficpo_carestd==.
replace effic1f=(5-efficpo_carerev)/4 if efficpo_carestd==. & effic_carestd==.
replace effic1f=(5-effic_carerev)/4 if efficpo_carestd==. & effic_carestd==. & efficpo_carerev==.
replace effic1f=(1-((efficpo_carerev+effic_carerev-2)/8)) if efficpo_carestd==. & effic_carestd==. & efficpo_carerev!=. & effic_carerev!=.
replace effic1f=(efficpo_carestd+effic_carestd-2)/8 if efficpo_carestd!=. & effic_carestd!=.

gen effic2f=(efficpo_saystd-1)/4
replace effic2f=(effic_saystd-1)/4 if efficpo_saystd==.
replace effic2f=(5-efficpo_sayrev)/4 if efficpo_saystd==. & effic_saystd==.
replace effic2f=(5-effic_sayrev)/4 if efficpo_saystd==. & effic_saystd==. & efficpo_sayrev==.
replace effic2f=(1-((efficpo_sayrev+effic_sayrev-2)/8)) if efficpo_sayrev!=. & effic_sayrev!=. & efficpo_saystd==. & effic_saystd==.
replace effic2f=(efficpo_saystd+effic_saystd-2)/8 if efficpo_saystd!=. & effic_saystd!=.

egen efficf=rowmean(effic1f effic2f)

* TRUST PEOPLE
* trustpf     L1. Would R say most people can be trusted
* trust_social DIFFERENT QUESTION WITH DIFFERENT RESPONSE OPTIONS
gen trustpf=(5-trust_social)/4
replace trustpf=. if trust_social==-9 | trust_social==-8


******************************************

* ft_dpc       B1a. Feeling Thermometer: president
* ftpo_pres Feeling Thermometer: president (POST)
* 777. Don't recognize
* 888. Don't know where to rate
* 889. Refused
* INAP. no post IW

gen ftobamapre=ft_dpc
gen ftobamapost=ftpo_pres
recode ft_dpc ftpo_pres ftobamapre ftobamapost (777=.) (888=.) (889=.) (-9/-1=.)

egen prestherm=rowmean(ft_dpc ftpo_pres)
gen prestherm1=prestherm/100

egen ftpres=rowmean(ftobamapre ftobamapost)

************************
* economic evaluations: national and personal; prospective and retrospective

tab1 econ_ecpast_x econ_ecnext_x finance_finnext_x finance_finpast_x
recode econ_ecpast_x econ_ecnext_x finance_finnext_x finance_finpast_x (-9/-8=.)

gen natpro=(5-econ_ecnext_x)/4
gen perpro=(5-finance_finnext_x)/4

egen econpro=rowmean(natpro perpro)

*****************

* Authoritarianism index
* V045208     N1a. Qualities for children: Independent or respect elders
* V045209     N1b. Qualities for children: Curiosity or good manners
* V045210     N1c. Qualities for children: Obedience or self-reliance
* V045211     N1d. Qualities for children: Considerate or well behaved

recode auth_ind auth_cur auth_obed auth_consid (-9/-1=.)
recode auth_ind auth_cur auth_obed auth_consid (4=.)

gen auth1=0.5
replace auth1=0 if auth_ind==1
replace auth1=1 if auth_ind==2

gen auth2=0.5
replace auth2=0 if auth_cur==1
replace auth2=1 if auth_cur==2

gen auth3=0.5
replace auth3=0 if auth_obed==2
replace auth3=1 if auth_obed==1

gen auth4=0.5
replace auth4=0 if auth_consid==1
replace auth4=1 if auth_consid==2

egen authf=rowmean(auth1 auth2 auth3 auth4)

******************

gen south=0
replace south=1 if sample_state=="AL" | sample_state=="AR" | sample_state=="FL" | sample_state=="GA" |sample_state=="LA" | sample_state=="MS" | sample_state=="NC" | sample_state=="SC" | sample_state=="TN" | sample_state=="TX" | sample_state=="VA"
* label variable south "Reside in South"
* label values south yesno

* Protestant
* V043247     X8x1. SUMMARY: RESPONDENT MAJOR RELIGIOUS GROUP
* V043230a    X3a. (Attends) R major religious group

gen prot=0
replace prot=1 if relig_7cat_x==1 | relig_7cat_x==2 | relig_7cat_x==3 | relig_7cat_x==5

****************************************

* AGE
recode dem_agegrp_iwdate (-2=.)

gen age1829=0
replace age1829=1 if dem_agegrp_iwdate< 4
replace age1829=. if dem_agegrp_iwdate==.

gen age3044=0
replace age3044=1 if dem_agegrp_iwdate>=4 & dem_agegrp_iwdate<7
replace age3044=. if dem_agegrp_iwdate==.

gen age4564=0
replace age4564=1 if dem_agegrp_iwdate>=7 & dem_agegrp_iwdate<11
replace age4564=. if dem_agegrp_iwdate==.

gen age65p=0
replace age65p=1 if dem_agegrp_iwdate>=11
replace age65p=. if dem_agegrp_iwdate==.

* Gender (remember, all dichotomous variables must be coded 0,1)
gen female=0
replace female=1 if gender_respondent==2

* NEW INCOME
* Income (28 pt. scale used in 2012 NES)
gen income=(incgroup_prepost)/28
replace income=0 if incgroup_prepost==-8 | incgroup_prepost==-9 

gen incnk=0
replace incnk=1 if incgroup_prepost==-8 | incgroup_prepost==-9

* Education
gen ba=0
replace ba=1 if dem_edugroup==4 | dem_edugroup==5
replace ba=. if dem_edugroup==-2 | dem_edugroup==-9

gen degree=(dem_edugroup-1)/4
replace degree=. if dem_edugroup==-2 | dem_edugroup==-9

* Ideology
recode libcpre_self (-9/-8=.)

gen ideology=libcpre_self-1
replace ideology=0 if libcpre_self==-2 | libcpre_self==.

gen ideoldk=0
replace ideoldk=1 if libcpre_self==-2 | libcpre_self==.

gen ideol1=ideology/6

* Partisanship
gen partyid=pid_x-1
replace partyid=. if pid_x==-2
gen pid1=partyid/6


***************************

gen inc1=income
gen incdk=incnk

gen year=2012

*******************************************************************************

**Stereotypes

recode stype_hwkblack stype_hwkwhite stype_hwkhisp stype_hwkasian stype_intwhite stype_intblack stype_inthisp stype_intasian (-9/-6=.)

gen whitehw=(stype_hwkwhite-1)/6
gen blackhw=(stype_hwkblack-1)/6

gen whitein=(stype_intwhite-1)/6
gen blackin=(stype_intblack-1)/6

egen whitester=rowmean(whitehw whitein)
egen blackster=rowmean(blackhw blackin)

*Black therm

* RACISM: AFFECT measure
recode ftcasi_black (-9/-6=.)
gen blacktherm1=ftcasi_black/100

**Policy variables 
**PREFERENTIAL HIRING - 
**Higher numbers strongly oppose

gen prefhire=.
replace prefhire=0 if aapost_hire_x==1
replace prefhire=0.33 if aapost_hire_x==2
replace prefhire=0.66 if aapost_hire_x==4
replace prefhire=1 if aapost_hire_x==1

**GOV HELP - SOME PEOPLE FEEL THAT THE GOVERNMENT IN WASHINGTON SHOULD MAKE EVERY EFFORT 
**TO IMPROVE THE SOCIAL AND ECONOMIC POSITION OF BLACKS. OTHERS FEEL THAT THE GOVERNMENT 
**SHOULD NOT MAKE ANY SPECIAL EFFORT TO HELP BLACKS BECAUSE THEY SHOULD HELP THEMSELVES
**Higher numbers strongly oppose
recode aidblack_self (-9/-2=.)
gen govhelp=(aidblack_self-1)/6

**immigration levels
recode immigpo_level (-9/-6=.)
gen immg=(immigpo_level-1)/4
tab immg

**************************************
**************************************

use "C:\Work_Kaplan\NES Data\NES_2016\anes_timeseries_2016_dta_may_02\anes_timeseries_2016.dta", clear


* for full, wieght using post election variables V160102.
* for full, wieght using pre election variables only V160101.

gen wgt=V160102

**************************************************************************

* trust
* V161215 PRE: REV How often trust govt in Wash to do what is right
* V161216 PRE: Govt run by a few big interests or for benefit of all
* V161217 PRE: Does government waste much tax money
* V161218 PRE: How many in government are corrupt

gen trustgov1=(5-V161215)/4
replace trustgov1=. if V161215==-8 | V161215==-9

gen trustgov2=V161216-1
replace trustgov2=. if V161216==-8 | V161216==-9

gen trustgov3=(V161217-1)/2
replace trustgov3=. if V161217==-8 | V161217==-9

gen trustgov4=(V161218-1)/4
replace trustgov4=. if V161218==-8 | V161218==-9

sum trustgov1 trustgov2 trustgov3 trustgov4
pwcorr trustgov1 trustgov2 trustgov3 trustgov4

egen trustgovf=rowmean(trustgov1 trustgov2 trustgov3 trustgov4)

gen trustgovo4=trustgov1*4

* responsiveness
recode V162215 V162216 (-9/-6=.)

gen effic1=(V162215-1)/4
gen effic2=(V162216-1)/4

egen efficf=rowmean(effic1 effic2)



* social trust
recode V161219 (-9=.)
gen trustpf=(5-V161219)/4


* presidential thermomenter
gen prestherm=V161092
recode prestherm (-99/-88=.)
gen prestherm1=prestherm/100


* prospective sociotropic economic evaluation
gen econpro=(5-V161141x)/4
replace econpro=. if V161141x==-1 | V161141x==-8 | V161141x==-9 | V161141x==-6


* authoritarianism
recode V162239 V162240 V162241 V162242 (-9/-6=.)

gen auth1=0.5
replace auth1=0 if V162239==1
replace auth1=1 if V162239==2

gen auth2=0.5
replace auth2=0 if V162240==1
replace auth2=1 if V162240==2

gen auth3=0.5
replace auth3=0 if V162241==2
replace auth3=1 if V162241==1

gen auth4=0.5
replace auth4=0 if V162242==1
replace auth4=1 if V162242==2

sum auth1 auth2 auth3 auth4
pwcorr auth1 auth2 auth3 auth4
egen authf=rowmean(auth1 auth2 auth3 auth4)

* race
gen white=0
replace white=1 if  V161310x==1
replace white=. if  V161310x==-9

gen black=0
replace black=1 if  V161310x==2
replace black=. if  V161310x==-9

gen hisp=0
replace hisp=1 if  V161310x==5
replace hisp=. if  V161310x==-9

gen other=1
replace other=0 if  white==1
replace other=0 if  black==1
replace other=0 if  hisp==1
replace other=. if  V161310x==-9

* age
gen age1829=0
replace age1829=1 if V161267>17  & V161267<30
replace age1829=. if V161267==-8 | V161267==-9

gen age3044=0
replace age3044=1 if V161267>29  & V161267<45
replace age3044=. if V161267==-8 | V161267==-9

gen age4564=0
replace age4564=1 if V161267>44  & V161267<65
replace age4564 =. if V161267==-8 | V161267==-9

gen age65p=0
replace age65p=1 if V161267>64
replace age65p=. if V161267==-8 | V161267==-9

* gender
* V161002 is gender as observed in FtF by interviewer; could use, but not doing so initially
gen female=0
replace female=1 if V161342==2
replace female=. if V161342==-9 | V161342==3
replace female=0 if V161342==-9 & V161002==1
replace female=1 if V161342==-9 & V161002==2

* education
gen ba=0
replace ba=1 if V161270==13 | V161270==14 | V161270==15 | V161270==16

gen ndegree=0
replace ndegree=1 if V161270==9
replace ndegree=2 if V161270==10 | V161270==11  | V161270==12
replace ndegree=3 if V161270==13
replace ndegree=4 if V161270==14 | V161270==15  | V161270==16
replace ndegree=. if V161270==-9  | V161270==95

gen degree=ndegree/4

* income

gen income=V161361x-1
replace income=. if V161361x<-3

gen inc1=V161361x/28
replace inc1=0 if V161361x==-9 | V161361x==-5

gen incdk=0
replace incdk=1 if V161361x==-9 | V161361x==-5

* party identification

* pid pre V161158x
gen partyid=V161158x-1
replace partyid=. if V161158x==-8 | V161158x==-9
gen pid1=partyid/6

* ideology
* lots of imputation
* when pressed in follow-up question, if say liberal or conservative, recode as liberal (1) or conservative (5)

gen ideoldk=0

gen ideology=V161126-1
replace ideology=1 if V161126==4 & V161127==1
replace ideology=5 if V161126==4 & V161127==2

replace ideology=1 if V161126==99 & V161127==1
replace ideology=3 if V161126==99 & V161127==3
replace ideology=5 if V161126==99 & V161127==2

replace ideology=0 if V161126==99 & V161127==-8
replace ideology=0 if V161126==99 & V161127==-9

replace ideoldk=1 if V161126==99 & V161127==-8
replace ideoldk=1 if V161126==99 & V161127==-9

replace ideology=1 if V161126==-8 & V161127==1
replace ideology=3 if V161126==-8 & V161127==3
replace ideology=5 if V161126==-8 & V161127==2

replace ideology=1 if V161126==-9 & V161127==1
replace ideology=3 if V161126==-9 & V161127==3
replace ideology=5 if V161126==-9 & V161127==2

replace ideology=0 if V161126==-8 & V161127==-8
replace ideology=0 if V161126==-8 & V161127==-9
replace ideology=0 if V161126==-9 & V161127==-8
replace ideology=0 if V161126==-9 & V161127==-9

replace ideoldk=1 if V161126==-8 & V161127==-8
replace ideoldk=1 if V161126==-8 & V161127==-9
replace ideoldk=1 if V161126==-9 & V161127==-8
replace ideoldk=1 if V161126==-9 & V161127==-9

gen ideol1=ideology/6

* south
* only 11 states (i.e., confederate states, but not border states of Missouri and Kentucky)
gen south=0
replace south=1 if V161010e=="AL" | V161010e=="AR" | V161010e=="FL" | V161010e=="GA" |V161010e=="LA" | V161010e=="MS" | V161010e=="NC" | V161010e=="SC" | V161010e=="TN" | V161010e=="TX" | V161010e=="VA"

* protestant
gen prot=0
replace prot=1 if V161247a==1  | V161247b==1

gen nprot=0
replace nprot=1 if V161247a==1


gen govthreat=.
gen ngovthreat=.

gen year=2016

*******************************************************************************

**Stereotypes
* V162345    Hardworking 7-pt scale: whites
* V162346    Hardworking 7-pt scale: blacks
* V162347    Hardworking 7-pt scale: hispanics
* V162348    Hardworking 7-pt scale: asians

* V162349    Peaceful 7-pt scale: whites
* V162350    Peaceful 7-pt scale: blacks
* V162351    Peaceful 7-pt scale: hispanics
* V162352    Peaceful 7-pt scale: asians

recode V162345 V162346 V162347 V162348 V001578 V001579 V001580 V001581 (-9/-5=.)

gen whitehw=(V162345-1)/6
gen blackhw=(V162346-1)/6

gen whitepe=(V162349-1)/6
gen blackpe=(V162350-1)/6


egen whitester=rowmean(whitehw whitepe)
egen blackster=rowmean(blackhw blackpe)

*Thermometers

*V162312 FEELING THERMOMETER: BLACKS
recode V162312 (-9/-5=.)
gen blacktherm1=V162312/100 
label value blacktherm1 blackthermL
label var blacktherm1 "Black Thermometer"
sum blacktherm1

**Policy variables 
**PREFERENTIAL HIRING - 
**Higher numbers strongly oppose

gen prefhire=.
replace prefhire=0 if V162238x==1
replace prefhire=0.33 if V162238x==2
replace prefhire=0.66 if V162238x==4
replace prefhire=1 if V162238x==1

**GOV HELP - SOME PEOPLE FEEL THAT THE GOVERNMENT IN WASHINGTON SHOULD MAKE EVERY EFFORT 
**TO IMPROVE THE SOCIAL AND ECONOMIC POSITION OF BLACKS. OTHERS FEEL THAT THE GOVERNMENT 
**SHOULD NOT MAKE ANY SPECIAL EFFORT TO HELP BLACKS BECAUSE THEY SHOULD HELP THEMSELVES
**Higher numbers strongly oppose
recode V161198 (-9/-8=.) (99=.)
gen govhelp=(V161198-1)/6


**immigration levels 
recode V162157 (-9/-6=.)
gen immg=(V162157-1)/4
tab immg

*******************************************************************************
**ANES 2020
*WEIGHTS

gen wgt_2020=V200010b
gen year=2020

********************************************************************************
*RECODING MISSINGS & INAPPLICABLES
********************************************************************************

**Eduardo use a diff stratgey here and coded all missing values for the variables he works with
**I exluded ideology and income from this group to be able to create income dk and ideology dk accordignly
recode V202328x V202265 V202354 V201001 V202423 V202424 V201427 V202490x V202493x V202494 V202495 V202496 V202497 V201258 V201345x V201314x V201311x V201317x V201320x V201323x V201252 V201302x V201305x V201435 V201436 V201455x V201233 V201234 V201235 V201236 V201237 V201238 V202430 V202583x V202586x V202587 V202588 V202589 V201324 V201327x V201330x V201333x V201334 V201335 V201502 V201503 V201594 V202527 V202528 V202529 V202530 V201553 V201555 V201562 V201563 V201565x V202001 V202266 V202267 V202268 V202269 V202259x V202256 V202255x V202252x V202300 V202301 V202302 V202303 V202480 V202477 V202478 V202479 V202481 V202482 V202483 V202484 V202485 V202490x V202493x V202494 V202495 V202496 V202497 V202498x V202499x V202504 V202505 V202506 V202515 V202516 V202517 V202518 V202519 V202520 V202521 V202522 V202523 V202524 V202525 V202526 V202527 V202528 V202529 V202530 V202531 V202532 V202533 V202534 V202535 V202536 V202537 V202263 V202262 V202261 V202260 V201231x  V201511x  V201549x V201546 V201562 V201554 V201507x V201600 V201617x (-9=.)
recode V202328x V202265 V202354 V201001 V202423 V202424 V201427 V202490x V202493x V202494 V202495 V202496 V202497 V201258 V201345x V201314x V201311x V201317x V201320x V201323x V201252 V201302x V201305x V201435 V201436 V201455x V201233 V201234 V201235 V201236 V201237 V201238 V202430 V202583x V202586x V202587 V202588 V202589 V201324 V201327x V201330x V201333x V201334 V201335 V201502 V201503 V201594 V202527 V202528 V202529 V202530 V201553 V201555 V201562 V201563 V201565x V202001 V202266 V202267 V202268 V202269 V202259x V202256 V202255x V202252x V202300 V202301 V202302 V202303 V202480 V202477 V202478 V202479 V202481 V202482 V202483 V202484 V202485 V202490x V202493x V202494 V202495 V202496 V202497 V202498x V202499x V202504 V202505 V202506 V202515 V202516 V202517 V202518 V202519 V202520 V202521 V202522 V202523 V202524 V202525 V202526 V202527 V202528 V202529 V202530 V202531 V202532 V202533 V202534 V202535 V202536 V202537 V202263 V202262 V202261 V202260 V201231x  V201511x  V201549x V201546 V201562 V201554 V201507x V201600 V201617x (-8=.)
recode V202328x V202265 V202354 V201001 V202423 V202424 V201427 V202490x V202493x V202494 V202495 V202496 V202497 V201258 V201345x V201314x V201311x V201317x V201320x V201323x V201252 V201302x V201305x V201435 V201436 V201455x V201233 V201234 V201235 V201236 V201237 V201238 V202430 V202583x V202586x V202587 V202588 V202589 V201324 V201327x V201330x V201333x V201334 V201335 V201502 V201503 V201594 V202527 V202528 V202529 V202530 V201553 V201555 V201562 V201563 V201565x V202001 V202266 V202267 V202268 V202269 V202259x V202256 V202255x V202252x V202300 V202301 V202302 V202303 V202480 V202477 V202478 V202479 V202481 V202482 V202483 V202484 V202485 V202490x V202493x V202494 V202495 V202496 V202497 V202498x V202499x V202504 V202505 V202506 V202515 V202516 V202517 V202518 V202519 V202520 V202521 V202522 V202523 V202524 V202525 V202526 V202527 V202528 V202529 V202530 V202531 V202532 V202533 V202534 V202535 V202536 V202537 V202263 V202262 V202261 V202260 V201231x  V201511x V201549x V201546 V201562 V201554 V201507x V201600 V201617x (-7=.)
recode V202328x V202265 V202354 V201001 V202423 V202424 V201427 V202490x V202493x V202494 V202495 V202496 V202497 V201258 V201345x V201314x V201311x V201317x V201320x V201323x V201252 V201302x V201305x V201435 V201436 V201455x V201233 V201234 V201235 V201236 V201237 V201238 V202430 V202583x V202586x V202587 V202588 V202589 V201324 V201327x V201330x V201333x V201334 V201335 V201502 V201503 V201594 V202527 V202528 V202529 V202530 V201553 V201555 V201562 V201563 V201565x V202001 V202266 V202267 V202268 V202269 V202259x V202256 V202255x V202252x V202300 V202301 V202302 V202303 V202480 V202477 V202478 V202479 V202481 V202482 V202483 V202484 V202485 V202490x V202493x V202494 V202495 V202496 V202497 V202498x V202499x V202504 V202505 V202506 V202515 V202516 V202517 V202518 V202519 V202520 V202521 V202522 V202523 V202524 V202525 V202526 V202527 V202528 V202529 V202530 V202531 V202532 V202533 V202534 V202535 V202536 V202537 V202263 V202262 V202261 V202260 V201231x  V201511x V201549x V201546 V201562 V201554 V201507x V201600 V201617x (-6=.)
recode V202328x V202265 V202354 V201001 V202423 V202424 V201427 V202490x V202493x V202494 V202495 V202496 V202497 V201258 V201345x V201314x V201311x V201317x V201320x V201323x V201252 V201302x V201305x V201435 V201436 V201455x V201233 V201234 V201235 V201236 V201237 V201238 V202430 V202583x V202586x V202587 V202588 V202589 V201324 V201327x V201330x V201333x V201334 V201335 V201502 V201503 V201594 V202527 V202528 V202529 V202530 V201553 V201555 V201562 V201563 V201565x V202001 V202266 V202267 V202268 V202269 V202259x V202256 V202255x V202252x V202300 V202301 V202302 V202303 V202480 V202477 V202478 V202479 V202481 V202482 V202483 V202484 V202485 V202490x V202493x V202494 V202495 V202496 V202497 V202498x V202499x V202504 V202505 V202506 V202515 V202516 V202517 V202518 V202519 V202520 V202521 V202522 V202523 V202524 V202525 V202526 V202527 V202528 V202529 V202530 V202531 V202532 V202533 V202534 V202535 V202536 V202537 V202263 V202262 V202261 V202260 V201231x  V201511x  V201549x V201546 V201562 V201554 V201507x V201600 V201617x (-5=.)
recode V202328x V202265 V202354 V201001 V202423 V202424 V201427 V202490x V202493x V202494 V202495 V202496 V202497 V201258 V201345x V201314x V201311x V201317x V201320x V201323x V201252 V201302x V201305x V201435 V201436 V201455x V201233 V201234 V201235 V201236 V201237 V201238 V202430 V202583x V202586x V202587 V202588 V202589 V201324 V201327x V201330x V201333x V201334 V201335 V201502 V201503 V201594 V202527 V202528 V202529 V202530 V201553 V201555 V201562 V201563 V201565x V202001 V202266 V202267 V202268 V202269 V202259x V202256 V202255x V202252x V202300 V202301 V202302 V202303 V202480 V202477 V202478 V202479 V202481 V202482 V202483 V202484 V202485 V202490x V202493x V202494 V202495 V202496 V202497 V202498x V202499x V202504 V202505 V202506 V202515 V202516 V202517 V202518 V202519 V202520 V202521 V202522 V202523 V202524 V202525 V202526 V202527 V202528 V202529 V202530 V202531 V202532 V202533 V202534 V202535 V202536 V202537 V202263 V202262 V202261 V202260 V201231x  V201511x  V201549x V201546 V201562 V201554 V201507x V201600 V201617x (-4=.)
recode V202328x V202265 V202354 V201001 V202423 V202424 V201427 V202490x V202493x V202494 V202495 V202496 V202497 V201258 V201345x V201314x V201311x V201317x V201320x V201323x V201252 V201302x V201305x V201435 V201436 V201455x V201233 V201234 V201235 V201236 V201237 V201238 V202430 V202583x V202586x V202587 V202588 V202589 V201324 V201327x V201330x V201333x V201334 V201335 V201502 V201503 V201594 V202527 V202528 V202529 V202530 V201553 V201555 V201562 V201563 V201565x V202001 V202266 V202267 V202268 V202269 V202259x V202256 V202255x V202252x V202300 V202301 V202302 V202303 V202480 V202477 V202478 V202479 V202481 V202482 V202483 V202484 V202485 V202490x V202493x V202494 V202495 V202496 V202497 V202498x V202499x V202504 V202505 V202506 V202515 V202516 V202517 V202518 V202519 V202520 V202521 V202522 V202523 V202524 V202525 V202526 V202527 V202528 V202529 V202530 V202531 V202532 V202533 V202534 V202535 V202536 V202537 V202263 V202262 V202261 V202260 V201231x  V201511x  V201549x V201546 V201562 V201554 V201507x V201600 V201617x (-3=.)
recode V202328x V202265 V202354 V201001 V202423 V202424 V201427 V202490x V202493x V202494 V202495 V202496 V202497 V201258 V201345x V201314x V201311x V201317x V201320x V201323x V201252 V201302x V201305x V201435 V201436 V201455x V201233 V201234 V201235 V201236 V201237 V201238 V202430 V202583x V202586x V202587 V202588 V202589 V201324 V201327x V201330x V201333x V201334 V201335 V201502 V201503 V201594 V202527 V202528 V202529 V202530 V201553 V201555 V201562 V201563 V201565x V202001 V202266 V202267 V202268 V202269 V202259x V202256 V202255x V202252x V202300 V202301 V202302 V202303 V202480 V202477 V202478 V202479 V202481 V202482 V202483 V202484 V202485 V202490x V202493x V202494 V202495 V202496 V202497 V202498x V202499x V202504 V202505 V202506 V202515 V202516 V202517 V202518 V202519 V202520 V202521 V202522 V202523 V202524 V202525 V202526 V202527 V202528 V202529 V202530 V202531 V202532 V202533 V202534 V202535 V202536 V202537 V202263 V202262 V202261 V202260 V201231x  V201511x  V201549x V201546 V201562 V201554 V201507x V201600 V201617x (-2=.)
recode V202328x V202265 V202354 V201001 V202423 V202424 V201427 V202490x V202493x V202494 V202495 V202496 V202497 V201258 V201345x V201314x V201311x V201317x V201320x V201323x V201252 V201302x V201305x V201435 V201436 V201455x V201233 V201234 V201235 V201236 V201237 V201238 V202430 V202583x V202586x V202587 V202588 V202589 V201324 V201327x V201330x V201333x V201334 V201335 V201502 V201503 V201594 V202527 V202528 V202529 V202530 V201553 V201555 V201562 V201563 V201565x V202001 V202266 V202267 V202268 V202269 V202259x V202256 V202255x V202252x V202300 V202301 V202302 V202303 V202480 V202477 V202478 V202479 V202481 V202482 V202483 V202484 V202485 V202490x V202493x V202494 V202495 V202496 V202497 V202498x V202499x V202504 V202505 V202506 V202515 V202516 V202517 V202518 V202519 V202520 V202521 V202522 V202523 V202524 V202525 V202526 V202527 V202528 V202529 V202530 V202531 V202532 V202533 V202534 V202535 V202536 V202537 V202263 V202262 V202261 V202260 V201231x  V201511x  V201549x V201546 V201562 V201554 V201507x V201600 V201617x (-1=.)
recode V202328x V202265 V202354 V201001 V202423 V202424 V201427 V202490x V202493x V202494 V202495 V202496 V202497 V201258 V201345x V201314x V201311x V201317x V201320x V201323x V201252 V201302x V201305x V201435 V201436 V201455x V201233 V201234 V201235 V201236 V201237 V201238 V202430 V202583x V202586x V202587 V202588 V202589 V201324 V201327x V201330x V201333x V201334 V201335 V201502 V201503 V201594 V202527 V202528 V202529 V202530 V201553 V201555 V201562 V201563 V201565x V202001 V202266 V202267 V202268 V202269 V202259x V202256 V202255x V202252x V202300 V202301 V202302 V202303 V202480 V202477 V202478 V202479 V202481 V202482 V202483 V202484 V202485 V202490x V202493x V202494 V202495 V202496 V202497 V202498x V202499x V202504 V202505 V202506 V202515 V202516 V202517 V202518 V202519 V202520 V202521 V202522 V202523 V202524 V202525 V202526 V202527 V202528 V202529 V202530 V202531 V202532 V202533 V202534 V202535 V202536 V202537 V202263 V202262 V202261 V202260 V201231x  V201511x  V201549x V201546 V201562 V201554 V201507x V201600 V201617x (99=.)


********************************************************************************
*RACE/ETHNCITY/HERITAGE (Uses a Pre-quex Summary Variable)

*Non-Hispanic White
gen white=.
replace white=0 if V201549x!=1 
replace white=1 if (V201549x==1 & V201546!=1)
label values white whiteL
label var white "Identifies as non-Hispanic white"
tab V201549x white

*Black (Uses a Pre-quex Summary Variable)
gen black=.
replace black=0 if V201549x!=2
replace black=1 if V201549x==2
label values black blackL
label var black "Identifies as AA/black"
tab V201549x black


*Latino (Uses a Pre-quex Summary Variable)
gen hisp=. 
replace hisp=0 if V201549x!=3
replace hisp=1 if V201549x==3 | V201546==1
label values hisp hispL
label var hisp "Identifies as Hispanic/Latino"
tab V201549x hisp
tab V201546 hisp

***********************
* AGE
*18-29
gen age1829=.
replace age1829=0 if V201507x > 29
replace age1829=1 if V201507x < 30
label values age1829 age1829L
label var age1829 "Age 18-29"
tab V201507x age1829

gen age3044=0
replace age3044=1 if V201507x > 29 & V201507x < 45
label values age3044 age3044L
label var age3044 "Age 30-44"
tab V201507x age3044

gen age4564=0
replace age4564=1 if V201507x > 44 & V201507x < 65
label values age4564 age4564L
label var age4564 "Age 45-64"
tab V201507x age4564

gen age65p=0
replace age65p=1 if V201507x>=65
label values age65p age65pL
label var age65p "Age 65 or older"
tab V201507x age65p

***********************
*Gender 
gen female=. 
replace female=0 if V201600==1
replace female=1 if V201600==2
label values female femaleL
label var female "Female Respondent"
tab female V201600

***********************
* INCOME
*pre-quex summary var is V201617x
*pre/post quex summary var is V202468x
*1. Under $9,999 2. $10,000-14,999
*3. $15,000-19,999 4. $20,000-24,999
*5. $25,000-29,999 6. $30,000-34,999
*7. $35,000-39,999 8. $40,000-44,999
*9. $45,000-49,999 10. $50,000-59,999
*11. $60,000-64,999 12. $65,000-69,999
*13. $70,000-74,999 14. $75,000-79,999
*15. $80,000-89,999 16. $90,000-99,999
*17. $100,000-109,999 18. $110,000-124,999
*19. $125,000-149,999 20. $150,000-174,999
*21. $175,000-249,999 22. $250,000 or more

*Using pre-quex summary
gen income_pre=(V201617x-1)/21 if V201617x > 0
label values income_pre income_preL
label var income_pre "Income PreQuex Sum"
tab V201617x income_pre

*Using pre/post-quex summary
gen income=(V202468x-1)/21 if V202468x > 0
label values income incomeL
label var income "Income Pre/Post Quex Sum"
tab V202468x income

*Creating similar income variables for the trust analysis
gen inc1=(V202468x-1)/21 
replace inc1=0 if if V202468x==-9 | V202468x==-5

gen incdk=0
replace incdk=1 if V202468x==-9 | V202468x==-5

***********************
* Education (Uses a Pre-quex Summary Variable)
*Coded here as BA equals y/n
gen degree=.
replace degree=0 if V201511x < 4
replace degree=1 if V201511x > 3 
label values degree degreeL
label var degree "Has At Least BA Degree"
tab degree V201511x

*Coded here where 0=Less than HS and 1=Grad Degree
gen educ1=(V201511x-1)/4
label values educ1 educ1L
label var educ1 "Education Level"
tab V201511x educ1

***********************
* PARTISANSHIP
gen pid1=(V201231x-1)/6
label value pid1 pid1L
label var pid1 "Strong Dem - Strong Rep"
tab V201231x pid1

********************************************************************************
* IDEOLOGY
*Var IDEOL_DUM aggregates responses from V201200 and V201201
*into one scale
*Var IDEOLOGY codes IDEOL_DUM on a 0-1 scale where 
*0=Extremely Liberal, 0.5=Moderate, and 1=Extremely Conservative
gen ideol_dum=.
replace ideol_dum=1 if V201200==1
replace ideol_dum=2 if V201200==2 | V201201==1
replace ideol_dum=3 if V201200==3 
replace ideol_dum=4 if V201201==3
replace ideol_dum=5 if V201200==5 
replace ideol_dum=6 if V201200==6 | V201201==2
replace ideol_dum=7 if V201200==7 
tab ideol_dum V201200
tab ideol_dum V201201

gen ideol1=(ideol_dum-1)/6
label value ideol1 ideol1L
label var ideol1 "Liberal - Conservative"
tab ideol_dum ideol1

**Ideology dk
gen ideoldk=0
replace ideoldk=1 if V201200==-9 | V201200==-8 | V201200==99 

***********************
* Authoritarianism index
*Higher values means more authoritarian
* V202266     N1a. Qualities for children: Independent or respect elders
* V202267     N1b. Qualities for children: Curiosity or good manners
* V202268     N1c. Qualities for children: Obedience or self-reliance
* V202269     N1d. Qualities for children: Considerate or well behaved
gen auth1=(V202266-1)/1 if V202266 < 3
tab V202266 auth1

gen auth2=(V202267-1)/1 if V202267 < 3
tab V202267 auth2

gen auth3=(2-V202268)/1 if V202268 < 3
tab V202268 auth3

gen auth4=(V202269-1)/1 if V202269 < 3
tab V202269 auth4

pwcorr auth1 auth2 auth3 auth4
factor auth1 auth2 auth3 auth4
rotate
factor auth1 auth2 auth3 auth4, fac(2)
rotate
factor auth1 auth2 auth3 auth4, fac(3)
rotate
factor auth1 auth2 auth3 auth4, fac (4)
rotate

*Alpha (Scale reliability coefficient) = 0.66
alpha auth1 auth2 auth3 auth4
egen authf=rowmean(auth1 auth2 auth3 auth4)
label value authf authfL
label var authf "Authoritarianism Level"
sum authf

***********************
*State of residence for respondent 
*not yet available for 2020 ANES release
*gen south=0
*replace south=1 if sample_state=="AL" | sample_state=="AR" | sample_state=="FL" | sample_state=="GA" |sample_state=="LA" | sample_state=="MS" | sample_state=="NC" | sample_state=="SC" | sample_state=="TN" | sample_state=="TX" | sample_state=="VA"
*label value south southL
*label var south "Resides in South"

***********************
*RELIGION & VALUES
* V201435     SUMMARY: RESPONDENT MAJOR RELIGIOUS GROUP
* V201436	  No religion stated (atheist, agnostic, xian, nothing)
* V201455x    Summary religious service attendance (not yet available)
* V202265	  Traditionalism
* Protestant
gen prot=0
replace prot=1 if V201435==1 
label value prot protL
label var prot "Protestant"
tab V201435 prot

***********************
* GOVT TRUST
* Higher Values means more trust
* V201233     M1a. How often trust government in Washington to do right
* V201234     M1b. Is govt run by few big interests or benefit of all
* V201235     M1c. How much does government waste tax money
* V201236     M1d. How many crooked people running government
gen trustgov1=(5-V201233)/4
tab V201233 trustgov1

gen trustgov2=(V201234-1)/1
tab V201234 trustgov2

gen trustgov3=(V201235-1)/2
tab V201235 trustgov3

gen trustgov4=(V201236-1)/4
tab V201236 trustgov4

pwcorr trustgov1 trustgov2 trustgov3 trustgov4
*Alpha (Scale reliability coefficient) = 0.62
alpha trustgov1 trustgov2 trustgov3 trustgov4

egen trustgovf=rowmean(trustgov1 trustgov2 trustgov3 trustgov4)
label value trustgovf trustgovfL
label var trustgovf "Level of Trust in Govt"
sum trustgovf

***********************

*responsiveness (efficacy)
recode V202212 V202213(-9/-4=.)
gen effic1=(V202212-1)/4
gen effic2=( V202213-1)/4

egen efficf=rowmean(effic1 effic2)
***********************
* TRUST PEOPLE
* V201237     L1. HOW OFTEN CAN PEOPLE BE TRUSTED
gen trustpf=(5-V201237)/4
label value trustpf trustpfL
label var trustpf "Can Trust People Never-Always"
tab V201237 trustpf

***********************
* Sociotropic/Retrospective ECONOMIC EVALUATION 
**higher = better evals

gen econpro=(5-V201330x)/4
label value econpro econproL
label var econpro "Pre: Prospective Econ Rating"
tab V201330x econpro


*******************************
*Stereotypes (Coded so that 1 = Group is Lazy/Violent)
*V202515 POST: STEREOTYPE: WHITES HARDWORKING
*V202516 POST: STEREOTYPE: BLACKS HARDWORKING

gen wht_lazy=(V202515-1)/6 
label value wht_lazy wht_lazyL
label var wht_lazy "Whites are Lazy"
tab V202515 wht_lazy
sum wht_lazy

gen blk_lazy=(V202516-1)/6
label value blk_lazy blk_lazyL
label var blk_lazy "Blacks are Lazy"
tab V202516 blk_lazy
sum blk_lazy


*V202521 POST: STEREOTYPE: WHITES VIOLENT
*V202522 POST: STEREOTYPE: BLACKS VIOLENT

gen wht_viol=(V202521-1)/6 
label value wht_viol wht_violL
label var wht_viol "Whites are Violent"
tab V202521 wht_viol
sum wht_viol

gen blk_viol=(V202522-1)/6 
label value blk_viol blk_violL
label var blk_viol "Blacks are Violent"
tab V202522 blk_viol
sum blk_viol


*Black Negative Stereotype Index
*alpha=.7154
alpha blk_lazy blk_viol
egen blk_stypes=rowmean (blk_lazy blk_viol)
label value blk_stypes blk_stypesL
label var blk_stypes "Negative Black Stereotypes"
sum blk_stypes

gen blackster=blk_ster

*Thermometers
*V202480	POST: FEELING THERMOMETER: BLACKS
gen blacktherm1=V202480/100 
label value blacktherm1 blackthermL
label var blacktherm1 "Black Thermometer"
sum blacktherm1

**Policy (only pref hire available)
**Preferential Hiring
gen prefhire=(V202252x-1)/3

*responsiveness (efficacy)
recode V202212 V202213(-9/-4=.)
gen effic1=(V202212-1)/4
gen effic2=( V202213-1)/4

egen efficf=rowmean(effic1 effic2)

*prestherm
recode V201152 (-9=.)
gen prestherm1=V201152/100
sum prestherm1

sum age1829 age3044 age4564 age65p female prot inc1 incdk degree pid1 ideol1 ideoldk prestherm1 authf trustpf econpro prefhire blackster trustgovf efficf if white==1 
pwcorr age1829 age3044 age4564 age65p female prot inc1 incdk degree pid1 ideol1 ideoldk prestherm1 authf trustpf econpro prefhire blackster trustgovf efficf if white==1 

**immigration levels 

recode V202232 (-9/-5=.)
gen immg=(V202232-1)/4
tab immg

********************************************************************************
**Models for the paper (1992-2016)
**DV: Trust in gov & efficacy 
**IVs: stereotypes,  policy, black therm, and immigration


eststo clear
eststo: reg trustgovf prefhire govhelp econpro trustpf authf prestherm1 pid1 ideol1 ideoldk age3044 age4564 age65p female prot south inc1 incdk degree if white==1 [pw=wgt]
estat sum

eststo: reg trustgovf blackster econpro trustpf authf prestherm1 pid1 ideol1 ideoldk age3044 age4564 age65p female prot south inc1 incdk degree if white==1 [pw=wgt]
estat sum

estout using "/Users/beb/Desktop/PB_RR.smcl", style(fixed) stats(N r2_a F p, fmt(4 3)) cells("b(star fmt(3))" se(par(`"="("'`")""')fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) replace
********************************************************************************
eststo clear

eststo: reg efficf prefhire govhelp econpro trustpf authf prestherm1 pid1 ideol1 ideoldk age3044 age4564 age65p female prot south inc1 incdk degree if white==1 [pw=wgt]
estat sum

eststo: reg efficf blackster econpro trustpf authf prestherm1 pid1 ideol1 ideoldk age3044 age4564 age65p female prot south inc1 incdk degree if white==1 [pw=wgt]
estat sum

estout using "/Users/beb/Desktop/PB_RR.smcl", style(fixed) stats(N r2_a F p, fmt(4 3)) cells("b(star fmt(3))" se(par(`"="("'`")""')fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) replace
********************************************************************************

eststo clear

eststo: reg trustgovf blacktherm1 econpro trustpf authf prestherm1 pid1 ideol1 ideoldk age3044 age4564 age65p female prot south inc1 incdk degree if white==1 [pw=wgt]
estat sum

eststo: reg trustgovf blackster blacktherm1 econpro trustpf authf prestherm1 pid1 ideol1 ideoldk age3044 age4564 age65p female prot south inc1 incdk degree if white==1 [pw=wgt]
estat sum

estout using "/Users/beb/Desktop/PB_RR.smcl", style(fixed) stats(N r2_a F p, fmt(4 3)) cells("b(star fmt(3))" se(par(`"="("'`")""')fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) replace

********************************************************************************
eststo clear

eststo: reg trustgovf immg blackster econpro trustpf authf prestherm1 pid1 ideol1 ideoldk age3044 age4564 age65p female prot south inc1 incdk degree if white==1 [pw=wgt]
estat sum

estout using "/Users/beb/Desktop/PB_RR.smcl", style(fixed) stats(N r2_a F p, fmt(4 3)) cells("b(star fmt(3))" se(par(`"="("'`")""')fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) replace
********************************************************************************
*2020
********************************************************************************
eststo clear

eststo: reg trustgovf blackster econ_pro trustpf authf prestherm1 partyid ideol1 ideoldk age3044 age4564 age65p female prot inc1 incdk ba if white==1 [pw=wgt]
estat sum

eststo: reg trustgovf prefhire econ_pro trustpf authf prestherm1 partyid ideol1 ideoldk age3044 age4564 age65p female prot inc1 incdk ba if white==1 [pw=wgt]
estat sum

estout using "/Users/beb/Desktop/PB_RR.smcl", style(fixed) stats(N r2_a F p, fmt(4 3)) cells("b(star fmt(3))" se(par(`"="("'`")""')fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) replace

********************************************************************************
eststo clear

eststo: reg efficf prefhire econ_pro trustpf authf prestherm1 partyid ideol1 ideoldk age3044 age4564 age65p female prot inc1 incdk ba if white==1 [pw=wgt]
estat sum

eststo: reg efficf blackster econ_pro trustpf authf prestherm1 partyid ideol1 ideoldk age3044 age4564 age65p female prot inc1 incdk ba if white==1 [pw=wgt]
estat sum

estout using "/Users/beb/Desktop/PB_RR.smcl", style(fixed) stats(N r2_a F p, fmt(4 3)) cells("b(star fmt(3))" se(par(`"="("'`")""')fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) replace

********************************************************************************
eststo clear

eststo: reg trustgovf blacktherm1 econ_pro trustpf authf prestherm1 partyid ideol1 ideoldk age3044 age4564 age65p female prot inc1 incdk ba if white==1 [pw=wgt]
estat sum

eststo: reg trustgovf blackster blacktherm1 econ_pro trustpf authf prestherm1 partyid ideol1 ideoldk age3044 age4564 age65p female prot inc1 incdk ba if white==1 [pw=wgt]
estat sum

estout using "/Users/beb/Desktop/PB_RR.smcl", style(fixed) stats(N r2_a F p, fmt(4 3)) cells("b(star fmt(3))" se(par(`"="("'`")""')fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) replace
********************************************************************************
eststo clear

eststo: reg trustgovf immg blackster econ_pro trustpf authf prestherm1 partyid ideol1 ideoldk age3044 age4564 age65p female prot inc1 incdk ba if white==1 [pw=wgt]
estat sum

estout using "/Users/beb/Desktop/PB_RR.smcl", style(fixed) stats(N r2_a F p, fmt(4 3)) cells("b(star fmt(3))" se(par(`"="("'`")""')fmt(2))) starlevels(* 0.10 ** 0.05 *** 0.01) replace




